const state = {
  currentAttr: {}, // 当前修改的attr属性
  isSub: false, // 当前操作的是主表还是子表
  subTable: {}, // 子表要绑定的字段
  templateJSON: {}, // 组合表单的字符串模板
  formAttrList: {}, // 表单中可以绑定的字段
  subFormList: {}, // 表单中子表可选择数组
  selectedKeys: {}, // 已经选择过的字段
  formData: {}, // 组合表单用来记录每个子表单的formList
  requestedReg: {}, // 已经请求过的正则规则
  isChangeVal: false, // 是否触发组件change事件
  currentObj: {}, // 当前触发组件的对象
  relaFieldsArr: [], // 当前触发组件下所含组件数据数组
  currentVal: {}, // 下拉框当前选中字段的当前数据对象
  currentField: '', // 下拉框当前选中字段的field
  isShowArr: [] // 组件详情中   添加操作中包含     `显隐`    操作方式  的  所有数据
}

const mutations = {
  UPDATE_ATTR: (state, value) => {
    state.currentAttr = value
  },
  UPDATE_SUB: (state, value) => {
    state.isSub = value
  },
  UPDATE_SUBTABLE: (state, value) => {
    state.subTable = value
  },
  UPDATE_TEMPLATEJSON: (state, value) => {
    state.templateJSON = value
  },
  UPDATE_FORMDATA: (state, value) => {
    state.formData = value
  },
  UPDATE_FORMATTR: (state, value) => {
    state.formAttrList = value
  },
  UPDATE_SUBFORMLIST: (state, value) => {
    state.subFormList = value
  },
  update_SELECTED_KEYS: (state, value) => {
    state.selectedKeys = value
  },
  update_RequestedReg: (state, value) => {
    state.requestedReg = value
  },
  UPDATE_ISCHANGEVAL: (state, value) => {
    state.isChangeVal = value
  },
  UPDATE_CURRENTOBJ: (state, value) => {
    state.currentObj = value
  },
  UPDATE_RELAFIELDSARR: (state, value) => {
    state.relaFieldsArr = value
  },
  UPDATE_CURRENTVAL: (state, value) => {
    state.currentVal = value
  },
  UPDATE_CURRENTFIELD: (state, value) => {
    state.currentField = value
  },
  UPDATE_ISSHOWARR: (state, value) => {
    state.isShowArr = value
  }
}

const actions = {
  changeAttr({ commit }, data) {
    commit('UPDATE_ATTR', data)
  },
  changeSub({ commit }, data) {
    commit('UPDATE_SUB', data)
  },
  changeSubTable({ commit }, data) {
    commit('UPDATE_SUBTABLE', data)
  },
  changeTemplate({ commit }, data) {
    commit('UPDATE_TEMPLATEJSON', data)
  },
  changeFormData({ commit }, data) {
    commit('UPDATE_FORMDATA', data)
  },
  changeFormAttr({ commit }, data) {
    commit('UPDATE_FORMATTR', data)
  },
  changeSubFormList({ commit }, data) {
    commit('UPDATE_SUBFORMLIST', data)
  },
  changeSelectedKeys({ commit }, data) {
    commit('update_SELECTED_KEYS', data)
  },
  changeRequestedReg({ commit }, data) {
    commit('update_RequestedReg', data)
  },
  changeIsChangeVal({ commit }, data) {
    commit('UPDATE_ISCHANGEVAL', data)
  },
  changeCurrentObj({ commit }, data) {
    commit('UPDATE_CURRENTOBJ', data)
  },
  changeRelaFieldsArr({ commit }, data) {
    commit('UPDATE_RELAFIELDSARR', data)
  },
  changecurrentVal({ commit }, data) {
    commit('UPDATE_CURRENTVAL', data)
  },
  changecurrentField({ commit }, data) {
    commit('UPDATE_CURRENTFIELD', data)
  },
  changeisShowArr({ commit }, data) {
    commit('UPDATE_ISSHOWARR', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
